﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace MES_SystemUI.Domain
{
    /// <summary>
    /// 用户表
    /// </summary>
    public class User
    {
        /// <summary>
        /// 用户主键，自动编号
        /// </summary>
        [Key]
        [DatabaseGenerated(DatabaseGeneratedOption.Identity)]
        [Description("用户主键")]
        public int UserId { get; set; }
        /// <summary>
        /// 用户名称，不能重复
        /// </summary>
        [Required]
        [Column(TypeName ="varchar")]
        [StringLength(20)]
        //[Index(IsUnique = true)]
        [Description("用户名称")]
        public string UserName { get; set; }
        /// <summary>
        /// 用户密码，密文,密码6-18位
        /// </summary>
        [Required]
        [Column(TypeName ="varchar")]
        [StringLength (50)]
        [Description("用户密码")]
        public string Password { get; set; }
        /// <summary>
        /// 用户手机号,手机号11位，防止特殊情况设置15位
        /// </summary>
        [Required]
        [Column(TypeName = "varchar")]
        [StringLength(15)]
        //[Index (IsUnique = true)]
        [Description("用户手机号")]
        public string Phone { get; set; }
        /// <summary>
        /// 数据状态（0正常，1删除）默认0
        /// </summary>
        [Required]
        [Description("数据状态")]
        public int Status { get; set; } = 0;
        /// <summary>
        /// 创建人，外键
        /// </summary>
        [Required]
        [Description("创建人")]
        public int CreateUserId { get; set; }
        /// <summary>
        /// 创建时间，默认当前时间
        /// </summary>
        [Required]
        [Description("创建时间")]
        public DateTime CreateTime { get; set; } = DateTime.Now;
        /// <summary>
        /// 最后一次修改人，外键
        /// </summary>
        [Description("最后一次修改人")]
        public int? LastUpdateUserId { get; set; }
        /// <summary>
        /// 最后一次修改时间
        /// </summary>
        [Description("最后一次修改时间")]
        public DateTime? LastUpdateTime { get; set; }
    }
}
